package com.yuandm.wxnt.util;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * @author Administrator
 * @time 2015/12/24 13:22
 * @des ${TODO}
 * @updateAuthor $Author$
 * @updateDate $Date$
 * @updateDes ${TODO}
 */
public class Sptools {
    public static void setString(Context context,String key,String value){
        SharedPreferences sp = context.getSharedPreferences("newscache", Context.MODE_PRIVATE);
        sp.edit().putString(key, value).commit();//提交保存键值对

    }

    /**
     * @param context
     * @param key
     *        关键字
     * @param defValue
     *        设置的默认值
     * @return
     */
    public static String getString(Context context,String key,String defValue){
        SharedPreferences sp = context.getSharedPreferences("newscache", Context.MODE_PRIVATE);
        return sp.getString(key, defValue);
    }
}
